package com.lazyframework.generator.configuration;

import com.lazyframework.generator.core.GenerateManager;
import com.lazyframework.generator.core.GenerateManagerImpl;
import com.lazyframework.generator.core.GenerateProvider;
import com.lazyframework.generator.core.MpGenerateProvider;
import com.lazyframework.generator.service.SchemaService;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.List;

@Configuration
public class GenerateConfiguration {

    /**
     * 初始化默认的ProviderManager
     */
    @Bean
    @ConditionalOnMissingBean(GenerateManager.class)
    public GenerateManager generateManager(SchemaService schemaService, List<GenerateProvider> providers) {
        return new GenerateManagerImpl(schemaService, providers);
    }

    /**
     * MyBatisPlus
     */
    @Bean
    public GenerateProvider mpGenerateProvider() {
        return new MpGenerateProvider();
    }

}
